package com.liwenfeng.diancanspringboot.mapper;

import com.github.pagehelper.Page;
import com.liwenfeng.diancanspringboot.annotation.AutoFill;
import com.liwenfeng.diancanspringboot.common.enumeration.OperationType;
import com.liwenfeng.diancanspringboot.pojo.dto.CategoryPageQueryDTO;
import com.liwenfeng.diancanspringboot.pojo.entity.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {

    Page<Category> selectByPage(CategoryPageQueryDTO categoryPageQueryDTO);

    @AutoFill(OperationType.INSERT)
    @Insert("insert into category (type, name, sort, create_time, update_time, create_user, update_user,status) values (#{type}, #{name}, #{sort}, now(), now(), #{createUser}, #{updateUser}, #{status})")
    void insert(Category category);

    @Delete("delete from category where id = #{id}")
    void delete(Long id);

    List<Category> list(Integer type);


    @AutoFill(OperationType.UPDATE)
    void update(Category category);

    @Select("select * from category where id = #{id}")
    Category getById(Long id);
}
